unit RelatorioBaixaCP;
  
interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, UFormRelatorio, QRCtrls, QuickRpt, DB, DBTables, ExtCtrls,
  StdCtrls;

type
  TFRelatorioBaixaCp = class(TFormRelatorio)
    QRGroup1: TQRGroup;
    QRBand3: TQRBand;
    QRBand2: TQRBand;
    QRDBTCheque: TQRDBText;
    QRDBTDataBaixa: TQRDBText;
    QRLDias: TQRLabel;
    QRDBTValorBaixa: TQRDBText;
    QRDBTJurosMulta: TQRDBText;
    QRDBTHistorico1: TQRDBText;
    QRDBTHistorico2: TQRDBText;
    QRLabel5: TQRLabel;
    QRLabel6: TQRLabel;
    QRLabel8: TQRLabel;
    QRLabel9: TQRLabel;
    QRLabel10: TQRLabel;
    QRLabel11: TQRLabel;
    QRLabel12: TQRLabel;
    QRLabel13: TQRLabel;
    QRLabel14: TQRLabel;
    QRLabel4: TQRLabel;
    QRLabel7: TQRLabel;
    QRLabel15: TQRLabel;
    QRLabel16: TQRLabel;
    QRLabel17: TQRLabel;
    QRLabel19: TQRLabel;
    QRDBTTitulo: TQRDBText;
    QRDBTDocumento: TQRDBText;
    QRDBTFornecedor: TQRDBText;
    QRDBText1: TQRDBText;
    qrdbCpHistorico2: TQRDBText;
    QRDBText3: TQRDBText;
    QRDBTValorTitulo: TQRDBText;
    QRDBTVencimento: TQRDBText;
    QRDBText4: TQRDBText;
    QRExpr1: TQRExpr;
    QRDBText5: TQRDBText;
    QRDBText2: TQRDBText;
    procedure QRBand2BeforePrint(Sender: TQRCustomBand;
      var PrintBand: Boolean);
    procedure FormCreate(Sender: TObject);
    procedure QRGroup1BeforePrint(Sender: TQRCustomBand;
      var PrintBand: Boolean);
    procedure QRLabel3Print(sender: TObject; var Value: String);
    procedure QRDBText2Print(sender: TObject; var Value: String);
  private
    { Private declarations }
  public
    { Public declarations }
   Titulo           :Integer;
   conta            :String;
   mudouConta       :Boolean;
  end;

var
  FRelatorioBaixaCp: TFRelatorioBaixaCp;

implementation

uses UGeral, PesquisaBaixaCP;

{$R *.dfm}

procedure TFRelatorioBaixaCp.QRBand2BeforePrint(Sender: TQRCustomBand;
  var PrintBand: Boolean);
var
 s :String;
begin
  inherited;
  if FPesquisaBaixaCp.QPesquisa.FieldByName('HISTORICO2').AsString = '' then
    QRBand2.Height := QRDBTHistorico2.Top
  else
    QRBand2.Height := QRDBTHistorico2.Top + QRDBTHistorico2.Height;

 s:=DiasRelatorio(1,-1,FPesquisaBaixaCp.QPesquisa.fieldByname('DataBaixa').AsFloat,FPesquisaBaixaCp.QPesquisa.fieldByname('DataVencimento').AsFloat);
 if S[1] = '-' then
  begin
   QRLDias.Caption:=Copy(s,1,3);
   QRLDias.Font.Color:=clRed;
  end
 else
  begin
   QRLDias.Caption:=Copy(s,1,2);
   QRLDias.Font.Color:=clBlack;
  end;

{ if(Titulo <> FPesquisaBaixaCp.QPesquisa.FieldByName('TITULO').AsInteger) or (mudouConta)  then
  begin
   Titulo:=FPesquisaBaixaCp.QPesquisa.FieldByName('TITULO').AsInteger;
   QRDBTTitulo.Width:=39;
   QRDBTDocumento.Width:=56;
   QRDBTFornecedor.Width:=263;
   QRDBTCheque.Width:=46;
   QRDBTValorTitulo.Width:=56;
   QRDBTVencimento.Width:=47;
   QRDBTHistorico1.Width:=298;
   QRDBTHistorico2.Width:=298;
  end
 else
  begin
   QRDBTTitulo.Width:=0;
   QRDBTDocumento.Width:=0;
   QRDBTFornecedor.Width:=0;
   QRDBTCheque.Width:=0;
   QRDBTValorTitulo.Width:=0;
   QRDBTVencimento.Width:=0;
   QRDBTHistorico1.Width:=0;
   QRDBTHistorico2.Width:=0;
  end;
 mudouConta:=false;}
end;

procedure TFRelatorioBaixaCp.FormCreate(Sender: TObject);
begin
  inherited;
{ Titulo:=0;
 conta:='';
 QRLConta.Caption:='';

 QRelatorio.Close;
 QRelatorio.SQL.Clear;
 QRelatorio.SQL.Add('Select Emp_Razao as Razao from empresa ');
 QRelatorio.SQL.Add('Where Emp_Codigo = :Cod ');
 QRelatorio.ParamByName('Cod').AsInteger:=Codigoempresa;
 QRelatorio.Open;
 QRLNomeEmpresa.Caption:=QRelatorio.fieldByname('Razao').AsString;}


end;

procedure TFRelatorioBaixaCp.QRGroup1BeforePrint(Sender: TQRCustomBand;
  var PrintBand: Boolean);
begin
  inherited;
{ if conta <> FPesquisaBaixaCp.QPesquisa.FieldByName('Conta').AsString then
  begin
   Conta:=FPesquisaBaixaCp.QPesquisa.FieldByName('Conta').AsString;
   QRLConta.Caption:=conta;
   mudouConta:=true;
   QRGroup1.Height:=21;
  end
 else
  begin
   QRLConta.Caption:='';
   mudouConta:=false;
   QRGroup1.Height:=0;
  end;                }
  if FPesquisaBaixaCp.QPesquisa.FieldByName('CP_HISTORICO2').AsString = '' then
    QRGroup1.Height := qrdbCpHistorico2.Top
  else
    QRGroup1.Height := qrdbCpHistorico2.Top + qrdbCpHistorico2.Height;
end;

procedure TFRelatorioBaixaCp.QRLabel3Print(sender: TObject;
  var Value: String);
begin
  inherited;
value:='';
end;

procedure TFRelatorioBaixaCp.QRDBText2Print(sender: TObject;
  var Value: String);
begin
  inherited;
  Value := 'BX' + value;
end;

end.
